<?xml version="1.0" encoding="utf-8" ?> 
<sqlMap namespace="Manager"
	xmlns="http://ibatis.apache.org/mapping" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<alias>
		<typeAlias alias="Manager" type="Domain.Manager" />
	</alias>

	<resultMaps>
		<resultMap id="FullResultMap" class="Manager">
			<result property="managerId" column="managerId" dbType="Int"/>
			<result property="managerName" column="managerName" dbType="NVarChar"/>
			<result property="managerPassword" column="managerPassword" dbType="NVarChar"/>
			<result property="managerRole" column="managerRole" dbType="NVarChar"/>
		</resultMap>
	</resultMaps>
	
	<statements>

		<select id="GetCount" resultClass="System.Int32">
			SELECT count(*) FROM [dbo].[manager]
		</select>
		
		<select id="GetCountByCondition" parameterClass="Hashtable" resultClass="System.Int32" extends="GetCount">
			WHERE $condition$
		</select>
		
		<select id="FindAll" resultClass="Manager">
			SELECT * 
			FROM [dbo].[manager]
		</select>
		
		<select id="GetModel" parameterClass="Manager" resultClass="Manager" extends="FindAll">
			WHERE
				([manager].[managerId] = #managerId,dbType=Int#)
		</select>

		<insert id="Insert" parameterClass="Manager">
			INSERT INTO [dbo].[manager] (
				
				[managerName] , 
				[managerPassword] , 
				[managerRole]
			) VALUES (
				
				 #managerName,dbType=NVarChar# , 
				 #managerPassword,dbType=NVarChar# , 
				 #managerRole,dbType=NVarChar#
			)
		</insert>

		<update id="Update" parameterClass="Manager">
			UPDATE [dbo].[manager] SET
				 [managerName] = #managerName,dbType=NVarChar#
				, [managerPassword] = #managerPassword,dbType=NVarChar#
				, [managerRole] = #managerRole,dbType=NVarChar#
			WHERE
				([managerId] = #managerId,dbType=Int#)
		</update>

		<delete id="Delete" parameterClass="Manager">
			DELETE FROM [dbo].[manager]
			WHERE
				([managerId] = #managerId,dbType=Int#)
		</delete>

		<select id="GetModelsByCondition" parameterClass="Hashtable" resultClass="Manager">
			SELECT $columnNames$ FROM [dbo].[manager] where $condition$
		</select>
		
		<select id="GetModelsByConditionByPager" parameterClass="Hashtable" resultClass="Manager">
			SELECT * FROM 
			(select $columnNames$,row_number() over(order by $orderBy$) as rno from [dbo].[manager] where $condition$) t 
			<![CDATA[
			where t.rno>#startNo# and t.rno<=#endNo#
			]]>
		</select>
		
	</statements>
</sqlMap>
